$OpenBSD: patch-cmake_Modules_DefineCompilerFlags_cmake,v 1.3 2014/03/09 20:41:14 rpointel Exp $

Check for compiler flags not available with gcc < 4.

--- cmake/Modules/DefineCompilerFlags.cmake.orig	Sat Dec 21 18:37:12 2013
+++ cmake/Modules/DefineCompilerFlags.cmake	Wed Jan  8 14:00:39 2014
@@ -11,9 +11,14 @@ if (UNIX AND NOT WIN32)
 
         # add -Wconversion ?
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors")
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement")
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security")
         set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
+
+	check_c_compiler_flag("-Wdeclaration-after-statement" WITH_WDECL)
+	if (WITH_WDECL)
+	    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wdeclaration-after-statement")
+        endif (WITH_WDECL)
 
         # with -fPIC
         check_c_compiler_flag("-fPIC" WITH_FPIC)
